package itheima.chap06;

public class Switchnotes {
    public static void main(String[] args) {
        String bodyType = "偏瘦";
        // switch的各种表现形式（switch比较时配对成功直接break跳出，但是if else要全部执行）
        // 1.原if else代码
       /* String goal;
        if (bodyType.equals("偏瘦")){
            goal = "增肌";
        } else if (bodyType.equals("超重") ||  bodyType.equals("肥胖")) {
            goal = "减重";
        } else {
            goal = "保持";
        }
        System.out.println("建议你接下来努力" + goal +"，加油！");
        }*/


        // 2.改成witch形式
        /*String goal;
        switch (bodyType) {
            case "偏瘦":
                goal = "增肌";
                break;
            case "超重":
                goal = "减重";
                break;
            case "肥胖":
                goal = "减重";
                break;
            default:
                goal = "保持";
                break;
        }*/


        // 3."减重"的两个判断条件可以合并，初步优化
        /*String goal;
        switch (bodyType) {
            case "偏瘦":
                goal = "增肌";
                break;
            case "超重":
            case "肥胖":
                goal = "减重";
                break;
            default:
                goal = "保持";
                break;
        }*/


        // 4.用->符号让格式变得更加优雅
        /*String goal;
        switch (bodyType) {
            case "偏瘦" -> goal = "增肌";
            case "超重", "肥胖" -> goal = "减重";
            default -> goal = "保持";
        }*/


        // 5.switch直接赋值
        String goal = switch (bodyType) {
            case "偏瘦" -> "增肌";
            case "超重", "肥胖" -> "减重";
            default -> "保持";
        };
        System.out.println("建议你接下来努力" + goal + "，加油！");


        // do while 与 while 的区别
        // do while 先执行一次，再判断条件
    }
}

